<template>
    <view @click="goNav()"><slot></slot></view>
</template>

<script lang="ts" setup>
    import { visitReportApi } from '@/api/Apps'
import { useGlobalStore } from '@/stores';
    import { defineProps } from 'vue'


    const globalStore = useGlobalStore()

    const props = defineProps<{
            url: string,
            id : number;
            name?:string;
            disabled?:boolean;
            linkType : number;
            qr : string;
        }>()

    const emit = defineEmits<{
        (e: 'success', data:any): void
    }>()

    function goNav() {
        if(props.disabled) return
        emit('success', {url : props.url, id : props.id, name : props.name, linkType:props.linkType, qr:props.qr})
        visitReportApi(props.id)
        if(props.linkType == 1) {
            location.href = props.url
        }else {
            globalStore.appQr.src = props.qr
            globalStore.appQr.show = true
        }
    }
</script>